keypath=/root/.ssh
iplist=`pwd`/yjs_ip
client_password=888Yijinsuo

if [ ! -e $iplist ]   
  then
    echo "please add server ip into ${iplist}" && touch ${iplist}
  else
    for  i in `more $iplist`
      do    
        ssh-keyscan $i >> ${keypath}/known_hosts
      done
fi

[ -d {keypath} ] || mkdir -p ${keypath} && chmod 700 /root/.ssh

dpkg -l|grep expect &> /dev/null || apt-get install expect -y

[[ -e ${keypath}/id_rsa.pub ]] || ssh-keygen -t rsa -f ${keypath}/id_rsa -P ""

while read ip;do
expect << EOF
    set timeout 5
    spawn ssh-copy-id -f $ip
    expect {
    "yes/no" { send "yes\n";exp_continue }
    "password" { send "$client_password\n"  }
    }
    expect off
EOF
done < ${iplist}

